% Chakram is a subproject of Hexena - Haskell Executable Analyser
% License:			GPL-3
% Maintainer:		Montez Fitzpatrick
% Stability:		Experimental
% Portability:		GHC
% Module:			Hexena.Codec.Parser.PEHeader

This is the @IMAGE_NT_HEADERS@ branch of the Portable Executable Format.  

Microsoft has the PE specification document located at:

[doc] <http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/pecoff_v8.docx>

\begin{code}
-- | ** IMAGE_NT_HEADERS **
module Hexena.Codec.Parser.PEHeader
	(
	-- * Parsing Functions
	  parsePeHeader
	) where

import Data.Binary.Get

import Hexena.Data.FileHeader (FileHeader(..))
import Hexena.Data.OptionalHeader (OptionalHeader(..))

import Hexena.Codec.Parser.FileHeader (parseFileHeader)
import Hexena.Codec.Parser.OptionalHeader (parseOptHeader)

-- | PE Header Parser
parsePeHeader :: Get PeHeader
parsePeHeader = do
  peh_sign <- getWord32le
  peh_fileHdr <- parseFileHeader
  peh_optHdr <- parseOptHeader

  return $ PeHeader peh_sign peh_fileHdr peh_optHdr
\end{code}
